home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / turbovis / tvtool17.zip / TVTOOLS.ZIP / BUTTONS.CPP < prev    next >
Text File  |  1993-01-14  |  1KB  |  49 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #define Uses_TButton
  4. #define Uses_TRect
  5. #define Uses_TWindow
  6. #define Uses_MsgBox
  7.  
  8. #include "tvtools.h"
  9.  
  10.  
  11. /***
  12.  *
  13.  *  Function   :    TwoButtons
  14.  *
  15.  *  Topics     :    Insert 2 buttons in a view.
  16.  *
  17.  *  Decisions  :    Insertion in the middle of the bottom of the view.
  18.  *                  OK button is default one.
  19.  *
  20.  *  Parameters :    in          TWindow *window
  21.  *                  in          int type     ( 0 = OK/Cancel, 1 = Yes/No )
  22.  *
  23.  *  Return     :    none
  24.  *
  25.  ***/
  26.  
  27.  
  28. void TwoButtons( TWindow *window, int type )
  29.  
  30. { const y = window->size.y - 3;
  31.   const buttonLen = 10;
  32.  
  33.   const char *label[] = { MsgBoxText::okText, MsgBoxText::yesText, MsgBoxText::cancelText, MsgBoxText::noText };
  34.  
  35.   ushort offset = ( window->size.x > 2 * buttonLen + 6 ) ? 3 : 1;
  36.  
  37.   ushort x = window->size.x / 2 - buttonLen - offset;
  38.   window->insert( new TButton(TRect(x, y, x + buttonLen, y + 2),
  39.                               label[type], cmOK, bfDefault
  40.                              )
  41.                 );
  42.  
  43.   x = window->size.x / 2 + offset;
  44.   window->insert( new TButton(TRect(x, y, x + buttonLen, y + 2),
  45.                               label[type + 2], cmCancel, bfNormal
  46.                              )
  47.                 );
  48. }
  49.